#include "StdAfx.h"
#include "Player.h"

#include "../Kernel.h"

extern Kernel* g_kernel;
extern irr::IrrlichtDevice*  g_IrrDevice;

Player::Player(void)
{
    g_kernel->GetConsole()->AddCommand( &f, "add" );
}

Player::~Player(void)
{
} 

 

irr::scene::IAnimatedMeshSceneNode* anms = NULL;
void Init()
{
    irr::scene::ISceneManager* m_IrrSceneMng = g_IrrDevice->getSceneManager();
        /*irr::scene::IAnimatedMeshSceneNode**/ anms = m_IrrSceneMng->addAnimatedMeshSceneNode( m_IrrSceneMng->getMesh("./sydney.md2"));
  //      anim = m_IrrSceneMng->createFlyStraightAnimator(core::vector3df(100,0,60), 
		//	                                    core::vector3df(-100,0,60), 10000, true);
		//anms->addAnimator(anim);
		//anim->drop();
        anms->setMaterialFlag(irr::video::EMF_LIGHTING, false);
        //anms->setFrameLoop(320, 360);
        anms->setMD2Animation( irr::scene::EMAT_SALUTE );

        anms->setAnimationSpeed(30);
        anms->setRotation(irr::core::vector3df(0,180.0f,0));
        anms->setMaterialTexture(0, g_IrrDevice->getVideoDriver()->getTexture("models/players/sarge/blue.tga"));
}


void Player::Update( float dt )
{
    //static bool b = false;
    //if (!b) { Init(); b= true; }

    if ( anms )
    {
        if ( g_kernel->GetInput()->IsKeyDown( MK_a ) )
            anms->setMD2Animation( irr::scene::EMAT_SALUTE );
        else if ( g_kernel->GetInput()->IsKeyDown( MK_s ) )
            anms->setMD2Animation( irr::scene::EMAT_RUN );
        else if ( g_kernel->GetInput()->IsKeyDown( MK_d ) )
            anms->setMD2Animation( irr::scene::EMAT_JUMP );

    }
}